function MinesField( config ) {
	var offsetX = 0;
	var offsetY = 0;
	var fieldSizeX = 0;
	var fieldSizeY = 0;
	var minesfield = [];
	var context;
	
	function initialize( config ) {
		if( typeof config != 'object' ) config = {};
		if( typeof config[ 'offsetX' ] == 'number' ) offsetX = config[ 'offsetX' ];
		if( typeof config[ 'offsetY' ] == 'number' ) offsetY = config[ 'offsetY' ];
		if( typeof config[ 'fieldSizeX' ] == 'number' ) fieldSizeX = config[ 'fieldSizeX' ];
		if( typeof config[ 'fieldSizeY' ] == 'number' ) fieldSizeY = config[ 'fieldSizeY' ];
		if( typeof config[ 'context' ] == 'object' ) context = config[ 'context' ];
	}
	
	this.drawMineField = function() {
		for( var x = 0; x < fieldSizeX; x++ ) {
			minesfield.push([]);
			for( var y = 0; y < fieldSizeY; y++ ) {
				minesfield[ x ].push( new Tile() );
			}
		}
		
		for( var y = 0; y < fieldSizeY; y++ ) {
			for( var x = 0; x < fieldSizeX; x++ ) {
				  
			}
		}
	};
	
	this.setBombs = function( percentage, excludeX, excludeY ) {
		var total = fieldSizeX * fieldSizeY;
		var bombs = Math.floor( percentage * total / 100 );
		
		var tiles = [];
		for( var i = 0; i < total; i++ ) tiles.push( i );
		tiles.splice( excludeY * fieldSizeX + excludeX, 1 );
		
		for( var i = 0; i < bombs; i++ ) {
			var rnd = Math.floor( Math.random() * tiles.length );
			
			var posX = Math.floor( tiles[ rnd ] / fieldSizeX );
			var posY = tiles[ rnd ] % fieldSizeX;
			
			tiles.splice( rnd, 1 );
			
			minesfield[ posX ][ posY ].setState( Tile.BOMB );
		}
	};
	
	initialize( config );
}

function Tile() {
	var tileState = Tile.EMPTY;
	var tileDiscovered = false;
	
	this.setState = function( s ) { tileState = s; };
	this.setDiscovered = function( d ) { tileDiscovered = d; };
	this.isDiscovered = function() { return tileDiscovered; };
	this.isBomb = function() { return ( tileState == Tile.BOMB ); };
	
	
}

Tile.EMPTY = 0;
Tile.BOMB = 1;